<template>
  <div :style="cfg.style_text" v-if="cfg.route.name != 'rinbot'">
    <n-config-provider v-if="cfg.run0 == true" :theme="$diycssbase[cfg.themename]">
      <n-notification-provider :placement="cfg.placement">
        <n-dialog-provider>
          <n-message-provider>
            <component :is="gt" />
          </n-message-provider>
        </n-dialog-provider>
      </n-notification-provider>
    </n-config-provider>
  </div>
  <div v-else-if="cfg.route.name == 'rinbot'">
    <component :is="rinbot" />
  </div>
</template>

<script>
import gt from "@/views/gt/main.vue";
import rinbot from "@/views/rinbot/main.vue";
import { useRoute, useRouter } from "vue-router";
import { cfg } from "./cfg/cfg.js";
import pkg from "/../package.json";

export default defineComponent({
  setup() {
    let ct = {};
    //内容区域大小
    ct.qypx = (v) => {
      cfg.qypx = v;
      localStorage.setItem("qypx", v);
      return;
    };
    cfg.themename = "darkTheme";
    cfg.token = localStorage.getItem("token");
    cfg.placement = "top";
    cfg.sswd = window.innerWidth;
    cfg.ver = pkg.version;

    const route = useRoute();
    const router = useRouter();

    cfg.route = route;
    cfg.router = router;
    router.isReady().then(() => {
      cfg.run0 = true;
    });

    onMounted(async () => {
      if (cfg.mobile == true) {
        await import("@/assets/mobile.css");
      }
    });

    return {
      cfg,
      gt,
      ct,
      rinbot,
    };
  },
});
</script>
